/**
 * Created by 55456 on 2016/5/15.
 */
var request = require("superagent");
var host = "127.0.0.1:3000";
var should = require("should");
describe("test login and register and validate user info",function(){
    var token;
    it("login should get token",function(done){
        request
            .post(host + "/user/login")
            .send({username:"test",pwd:"test"})
            .end(function(err,res){
                var data = JSON.parse(res.text);
                token = data.token;
                data.token.should.be.exactly("/IUIdFJpblvL47enH94A4yCvLMo=");
                done();
            });
    });
    
    it("should get user after login",function(done){
        request
            .post(host + "/user/test")
            .send({token:token})
            .end(function(err,res){
                var data = JSON.parse(res.text);
                data.type.should.be.exactly("admin");
                done();
            });
    });
});